<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="公司名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入公司名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编号" prop="materialNumber">
        <el-input
          v-model="queryParams.materialNumber"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料子号" prop="materialSubnumber">
        <el-input
          v-model="queryParams.materialSubnumber"
          placeholder="请输入物料子号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="materialName">
        <el-input
          v-model="queryParams.materialName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="specification">
        <el-input
          v-model="queryParams.specification"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="年度采购计划号" prop="annualPurchasePlanNumber">
        <el-input
          v-model="queryParams.annualPurchasePlanNumber"
          placeholder="请输入年度采购计划号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="季度采购计划号" prop="quarterlyPurchasePlanNumber">
        <el-input
          v-model="queryParams.quarterlyPurchasePlanNumber"
          placeholder="请输入季度采购计划号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="月度采购计划号" prop="monthlyPurchasePlanNumber">
        <el-input
          v-model="queryParams.monthlyPurchasePlanNumber"
          placeholder="请输入月度采购计划号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="条码号" prop="barcode">
        <el-input
          v-model="queryParams.barcode"
          placeholder="请输入条码号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商名称" prop="supplierName">
        <el-input
          v-model="queryParams.supplierName"
          placeholder="请输入供应商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="制造商名称" prop="manufacturerName">
        <el-input
          v-model="queryParams.manufacturerName"
          placeholder="请输入制造商名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同号" prop="contractNumber">
        <el-input
          v-model="queryParams.contractNumber"
          placeholder="请输入合同号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sales:NcPurchaseOrderTotal:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['sales:NcPurchaseOrderTotal:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['sales:NcPurchaseOrderTotal:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['sales:NcPurchaseOrderTotal:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="info"
            plain
            icon="el-icon-upload2"
            size="mini"
            @click="handleImport"
        >导入</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="NcPurchaseOrderTotalList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键ID" align="center" prop="id" />
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="公司名称" align="center" prop="factoryName" />
      <el-table-column label="物料类型" align="center" prop="materialType" />
      <el-table-column label="物料编号" align="center" prop="materialNumber" />
      <el-table-column label="物料子号" align="center" prop="materialSubnumber" />
      <el-table-column label="物料名称" align="center" prop="materialName" />
      <el-table-column label="规格型号" align="center" prop="specification" />
      <el-table-column label="物料计量单位" align="center" prop="materialUnit" />
      <el-table-column label="计划类型" align="center" prop="planType" />
      <el-table-column label="年度采购计划号" align="center" prop="annualPurchasePlanNumber" />
      <el-table-column label="年度采购计划数量" align="center" prop="annualPurchasePlanQuantity" />
      <el-table-column label="季度采购计划号" align="center" prop="quarterlyPurchasePlanNumber" />
      <el-table-column label="季度采购计划数量" align="center" prop="quarterlyPurchasePlanQuantity" />
      <el-table-column label="月度采购计划号" align="center" prop="monthlyPurchasePlanNumber" />
      <el-table-column label="月度采购计划数量" align="center" prop="monthlyPurchasePlanQuantity" />
      <el-table-column label="条码号" align="center" prop="barcode" />
      <el-table-column label="供应商编码" align="center" prop="supplierCode" />
      <el-table-column label="供应商名称" align="center" prop="supplierName" />
      <el-table-column label="制造商代码" align="center" prop="manufacturerCode" />
      <el-table-column label="制造商名称" align="center" prop="manufacturerName" />
      <el-table-column label="合同状态" align="center" prop="contractStatus" />
      <el-table-column label="合同号" align="center" prop="contractNumber" />
      <el-table-column label="合同份额" align="center" prop="contractShare" />
      <el-table-column label="合同数量" align="center" prop="contractQuantity" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="金额" align="center" prop="amount" />
      <el-table-column label="计划价格" align="center" prop="planPrice" />
      <el-table-column label="计划金额" align="center" prop="planAmount" />
      <el-table-column label="含税采购价格" align="center" prop="taxIncludedPurchasePrice" />
      <el-table-column label="含税采购金额" align="center" prop="taxIncludedPurchaseAmount" />
      <el-table-column label="不含税采购价格" align="center" prop="taxExcludedPurchasePrice" />
      <el-table-column label="不含税采购金额" align="center" prop="taxExcludedPurchaseAmount" />
      <el-table-column label="托管属性" align="center" prop="custodyAttribute" />
      <el-table-column label="要货类型" align="center" prop="demandType" />
      <el-table-column label="要货单位" align="center" prop="demandUnit" />
      <el-table-column label="订货单位" align="center" prop="orderingUnit" />
      <el-table-column label="订货仓库" align="center" prop="orderingWarehouse" />
      <el-table-column label="收货单位" align="center" prop="receivingUnit" />
      <el-table-column label="收货人" align="center" prop="receivingPerson" />
      <el-table-column label="收货地址" align="center" prop="receivingAddress" />
      <el-table-column label="电话" align="center" prop="phone" />
      <el-table-column label="材质" align="center" prop="material" />
      <el-table-column label="包装尺寸" align="center" prop="packagingSize" />
      <el-table-column label="包装材质" align="center" prop="packagingMaterial" />
      <el-table-column label="单箱重量" align="center" prop="singleBoxWeight" />
      <el-table-column label="状态" align="center" prop="status" />
      <el-table-column label="申请人" align="center" prop="applicant" />
      <el-table-column label="采购人" align="center" prop="purchaser" />
      <el-table-column label="编制人" align="center" prop="compiler" />
      <el-table-column label="审批人" align="center" prop="approver" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['sales:NcPurchaseOrderTotal:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['sales:NcPurchaseOrderTotal:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改采购订单总对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="90px">
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="公司代码" prop="factoryCode">
              <el-input v-model="form.factoryCode" placeholder="请输入公司代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="公司名称" prop="factoryName">
              <el-input v-model="form.factoryName" placeholder="请输入公司名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料编号" prop="materialNumber">
              <el-input v-model="form.materialNumber" placeholder="请输入物料编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料子号" prop="materialSubnumber">
              <el-input v-model="form.materialSubnumber" placeholder="请输入物料子号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料名称" prop="materialName">
              <el-input v-model="form.materialName" placeholder="请输入物料名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="规格型号" prop="specification">
              <el-input v-model="form.specification" placeholder="请输入规格型号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="物料计量单位" prop="materialUnit">
              <el-input v-model="form.materialUnit" placeholder="请输入物料计量单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年度采购计划号" prop="annualPurchasePlanNumber">
              <el-input v-model="form.annualPurchasePlanNumber" placeholder="请输入年度采购计划号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年度采购计划数量" prop="annualPurchasePlanQuantity">
              <el-input v-model="form.annualPurchasePlanQuantity" placeholder="请输入年度采购计划数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="季度采购计划号" prop="quarterlyPurchasePlanNumber">
              <el-input v-model="form.quarterlyPurchasePlanNumber" placeholder="请输入季度采购计划号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="季度采购计划数量" prop="quarterlyPurchasePlanQuantity">
              <el-input v-model="form.quarterlyPurchasePlanQuantity" placeholder="请输入季度采购计划数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月度采购计划号" prop="monthlyPurchasePlanNumber">
              <el-input v-model="form.monthlyPurchasePlanNumber" placeholder="请输入月度采购计划号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="月度采购计划数量" prop="monthlyPurchasePlanQuantity">
              <el-input v-model="form.monthlyPurchasePlanQuantity" placeholder="请输入月度采购计划数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="条码号" prop="barcode">
              <el-input v-model="form.barcode" placeholder="请输入条码号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商编码" prop="supplierCode">
              <el-input v-model="form.supplierCode" placeholder="请输入供应商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供应商名称" prop="supplierName">
              <el-input v-model="form.supplierName" placeholder="请输入供应商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造商代码" prop="manufacturerCode">
              <el-input v-model="form.manufacturerCode" placeholder="请输入制造商代码" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="制造商名称" prop="manufacturerName">
              <el-input v-model="form.manufacturerName" placeholder="请输入制造商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同号" prop="contractNumber">
              <el-input v-model="form.contractNumber" placeholder="请输入合同号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同份额" prop="contractShare">
              <el-input v-model="form.contractShare" placeholder="请输入合同份额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="合同数量" prop="contractQuantity">
              <el-input v-model="form.contractQuantity" placeholder="请输入合同数量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单价" prop="unitPrice">
              <el-input v-model="form.unitPrice" placeholder="请输入单价" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="金额" prop="amount">
              <el-input v-model="form.amount" placeholder="请输入金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划价格" prop="planPrice">
              <el-input v-model="form.planPrice" placeholder="请输入计划价格" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划金额" prop="planAmount">
              <el-input v-model="form.planAmount" placeholder="请输入计划金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="含税采购价格" prop="taxIncludedPurchasePrice">
              <el-input v-model="form.taxIncludedPurchasePrice" placeholder="请输入含税采购价格" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="含税采购金额" prop="taxIncludedPurchaseAmount">
              <el-input v-model="form.taxIncludedPurchaseAmount" placeholder="请输入含税采购金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="不含税采购价格" prop="taxExcludedPurchasePrice">
              <el-input v-model="form.taxExcludedPurchasePrice" placeholder="请输入不含税采购价格" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="不含税采购金额" prop="taxExcludedPurchaseAmount">
              <el-input v-model="form.taxExcludedPurchaseAmount" placeholder="请输入不含税采购金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="托管属性" prop="custodyAttribute">
              <el-input v-model="form.custodyAttribute" placeholder="请输入托管属性" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="要货单位" prop="demandUnit">
              <el-input v-model="form.demandUnit" placeholder="请输入要货单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订货单位" prop="orderingUnit">
              <el-input v-model="form.orderingUnit" placeholder="请输入订货单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订货仓库" prop="orderingWarehouse">
              <el-input v-model="form.orderingWarehouse" placeholder="请输入订货仓库" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货单位" prop="receivingUnit">
              <el-input v-model="form.receivingUnit" placeholder="请输入收货单位" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货人" prop="receivingPerson">
              <el-input v-model="form.receivingPerson" placeholder="请输入收货人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收货地址" prop="receivingAddress">
              <el-input v-model="form.receivingAddress" placeholder="请输入收货地址" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="电话" prop="phone">
              <el-input v-model="form.phone" placeholder="请输入电话" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="材质" prop="material">
              <el-input v-model="form.material" placeholder="请输入材质" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装尺寸" prop="packagingSize">
              <el-input v-model="form.packagingSize" placeholder="请输入包装尺寸" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装材质" prop="packagingMaterial">
              <el-input v-model="form.packagingMaterial" placeholder="请输入包装材质" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单箱重量" prop="singleBoxWeight">
              <el-input v-model="form.singleBoxWeight" placeholder="请输入单箱重量" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="申请人" prop="applicant">
              <el-input v-model="form.applicant" placeholder="请输入申请人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="采购人" prop="purchaser">
              <el-input v-model="form.purchaser" placeholder="请输入采购人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="编制人" prop="compiler">
              <el-input v-model="form.compiler" placeholder="请输入编制人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审批人" prop="approver">
              <el-input v-model="form.approver" placeholder="请输入审批人" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
          ref="upload"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url + '?updateSupport=' + upload.updateSupport"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!--  <div class="el-upload__tip" slot="tip">
              <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
            </div>-->
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listNcPurchaseOrderTotal, getNcPurchaseOrderTotal, delNcPurchaseOrderTotal, addNcPurchaseOrderTotal, updateNcPurchaseOrderTotal } from "@/api/sales/NcPurchaseOrderTotal";
import {getToken} from "@/utils/auth";
export default {
  name: "NcPurchaseOrderTotal",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采购订单总表格数据
      NcPurchaseOrderTotalList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        factoryName: null,
        materialType: null,
        materialNumber: null,
        materialSubnumber: null,
        materialName: null,
        specification: null,
        planType: null,
        annualPurchasePlanNumber: null,
        quarterlyPurchasePlanNumber: null,
        monthlyPurchasePlanNumber: null,
        barcode: null,
        supplierName: null,
        manufacturerName: null,
        contractNumber: null,
        demandType: null,
      },
      upload: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "导入`NcPurchaseOrderTotal`信息",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/sales/NcPurchaseOrderTotal/importData"
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询采购订单总列表 */
    getList() {
      this.loading = true;
      listNcPurchaseOrderTotal(this.queryParams).then(response => {
        this.NcPurchaseOrderTotalList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryCode: null,
        factoryName: null,
        materialType: null,
        materialNumber: null,
        materialSubnumber: null,
        materialName: null,
        specification: null,
        materialUnit: null,
        planType: null,
        annualPurchasePlanNumber: null,
        annualPurchasePlanQuantity: null,
        quarterlyPurchasePlanNumber: null,
        quarterlyPurchasePlanQuantity: null,
        monthlyPurchasePlanNumber: null,
        monthlyPurchasePlanQuantity: null,
        barcode: null,
        supplierCode: null,
        supplierName: null,
        manufacturerCode: null,
        manufacturerName: null,
        contractStatus: null,
        contractNumber: null,
        contractShare: null,
        contractQuantity: null,
        unitPrice: null,
        amount: null,
        planPrice: null,
        planAmount: null,
        taxIncludedPurchasePrice: null,
        taxIncludedPurchaseAmount: null,
        taxExcludedPurchasePrice: null,
        taxExcludedPurchaseAmount: null,
        custodyAttribute: null,
        demandType: null,
        demandUnit: null,
        orderingUnit: null,
        orderingWarehouse: null,
        receivingUnit: null,
        receivingPerson: null,
        receivingAddress: null,
        phone: null,
        material: null,
        packagingSize: null,
        packagingMaterial: null,
        singleBoxWeight: null,
        status: null,
        applicant: null,
        purchaser: null,
        compiler: null,
        approver: null,
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加采购订单总";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getNcPurchaseOrderTotal(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改采购订单总";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateNcPurchaseOrderTotal(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addNcPurchaseOrderTotal(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除数据？').then(function() {
        return delNcPurchaseOrderTotal(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('sales/NcPurchaseOrderTotal/export', {
        ...this.queryParams
      }, `NcPurchaseOrderTotal_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "采购订单总导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download('sales/NcPurchaseOrderTotal/importTemplate', {
      }, `采购订单总模板.xlsx`)
    },
    /** 文件上传中处理 */
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件上传成功处理 */
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    /** 提交上传文件 */
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
